/*! 
\file 
	UserDataTypeInfo.cpp
\brief
	Definition of UserDataTypeInfo.
*/

#include <algorithm>

#include "ClassType.h"

namespace ObjectModel
{
	ClassType::ClassType(const wchar_t* name, const TypeHierarchy& manager,
		const wchar_t* description/* = 0*/)
						: Type(name, manager, description), _basicClass(0)
	{
	}


	int ClassType::getSize() const
	{
		int size = 0;
		
		for (ClassType::Attributes::const_iterator i = _attributes.begin();
				i != _attributes.end(); ++i)
		{
			size += i->getType().getSize();
		}
		return size;
	}

	//! Add attribute.
	Attribute& ClassType::addAttribute(const wchar_t* name, Type& type, 
		ClassMemberAccess access/* = ClassMemberAccessPrivate*/,
		const wchar_t* description/* = 0*/)
	{
		_attributes.push_back(Attribute(name, type, access, description));
		return *_attributes.rbegin();
	}

	//! Add method.
	Method& ClassType::addMethod(const wchar_t* name,
		const Type& return_type, bool isPure, 
		ClassMemberAccess access/* = ClassMemberAccessPublic*/,
		const wchar_t* description/* = L""*/)
	{
		_methods.push_back(Method(name, return_type, isPure,
			access, description));
		return *_methods.rbegin();
	}
}
